load("//bazel:build.bzl", "redpanda_cc_library")

package(default_visibility = ["//src/v/kafka/client:__subpackages__"])

redpanda_cc_library(
    name = "logger",
    hdrs = ["logger.h"],
    deps = [
        "//src/v/base",
        "//src/v/utils:truncating_logger",
        "@seastar",
    ],
)

redpanda_cc_library(
    name = "errors",
    hdrs = ["errors.h"],
    deps = [
        "//src/v/base",
        "//src/v/kafka/protocol",
    ],
)

redpanda_cc_library(
    name = "api_types",
    hdrs = ["api_types.h"],
    deps = [
        "//src/v/base",
        "//src/v/kafka/protocol:add_offsets_to_txn",
        "//src/v/kafka/protocol:add_partitions_to_txn",
        "//src/v/kafka/protocol:alter_client_quotas",
        "//src/v/kafka/protocol:alter_configs",
        "//src/v/kafka/protocol:alter_partition_reassignments",
        "//src/v/kafka/protocol:alter_user_scram_credentials",
        "//src/v/kafka/protocol:api_versions",
        "//src/v/kafka/protocol:create_acls",
        "//src/v/kafka/protocol:create_partitions",
        "//src/v/kafka/protocol:create_topics",
        "//src/v/kafka/protocol:delete_acls",
        "//src/v/kafka/protocol:delete_groups",
        "//src/v/kafka/protocol:delete_records",
        "//src/v/kafka/protocol:delete_topics",
        "//src/v/kafka/protocol:describe_acls",
        "//src/v/kafka/protocol:describe_client_quotas",
        "//src/v/kafka/protocol:describe_cluster",
        "//src/v/kafka/protocol:describe_configs",
        "//src/v/kafka/protocol:describe_groups",
        "//src/v/kafka/protocol:describe_log_dirs",
        "//src/v/kafka/protocol:describe_producers",
        "//src/v/kafka/protocol:describe_transactions",
        "//src/v/kafka/protocol:describe_user_scram_credentials",
        "//src/v/kafka/protocol:end_txn",
        "//src/v/kafka/protocol:fetch",
        "//src/v/kafka/protocol:find_coordinator",
        "//src/v/kafka/protocol:heartbeat",
        "//src/v/kafka/protocol:incremental_alter_configs",
        "//src/v/kafka/protocol:init_producer_id",
        "//src/v/kafka/protocol:join_group",
        "//src/v/kafka/protocol:leave_group",
        "//src/v/kafka/protocol:list_groups",
        "//src/v/kafka/protocol:list_offset",
        "//src/v/kafka/protocol:list_partition_reassignments",
        "//src/v/kafka/protocol:list_transactions",
        "//src/v/kafka/protocol:messages",
        "//src/v/kafka/protocol:metadata",
        "//src/v/kafka/protocol:offset_commit",
        "//src/v/kafka/protocol:offset_delete",
        "//src/v/kafka/protocol:offset_fetch",
        "//src/v/kafka/protocol:offset_for_leader_epoch",
        "//src/v/kafka/protocol:produce",
        "//src/v/kafka/protocol:sasl_authenticate",
        "//src/v/kafka/protocol:sasl_handshake",
        "//src/v/kafka/protocol:sync_group",
        "//src/v/kafka/protocol:txn_offset_commit",
        "@seastar",
    ],
)

redpanda_cc_library(
    name = "configuration",
    srcs = ["configuration.cc"],
    hdrs = ["configuration.h"],
    visibility = ["//visibility:public"],
    deps = [
        ":logger",
        "//src/v/base",
        "//src/v/config",
        "//src/v/net:tls",
        "//src/v/security",
        "@fmt",
        "@seastar",
    ],
)

redpanda_cc_library(
    name = "exceptions",
    srcs = [],
    hdrs = ["exceptions.h"],
    visibility = ["//visibility:public"],
    deps = [
        ":logger",
        "//src/v/base",
        "//src/v/kafka/protocol",
        "@fmt",
        "@seastar",
    ],
)

redpanda_cc_library(
    name = "config_utils",
    srcs = ["config_utils.cc"],
    hdrs = ["config_utils.h"],
    visibility = ["//visibility:public"],
    deps = [
        ":configuration",
        "//src/v/base",
        "//src/v/cluster",
        "//src/v/config",
        "//src/v/security",
        "@seastar",
    ],
)

redpanda_cc_library(
    name = "transport",
    srcs = ["transport.cc"],
    hdrs = ["transport.h"],
    visibility = ["//visibility:public"],
    deps = [
        ":logger",
        "//src/v/base",
        "//src/v/bytes:iostream",
        "//src/v/bytes:scattered_message",
        "//src/v/kafka/protocol",
        "//src/v/kafka/protocol:api_versions",
        "//src/v/kafka/protocol:create_topics",
        "//src/v/kafka/protocol:delete_records",
        "//src/v/kafka/protocol:describe_configs",
        "//src/v/kafka/protocol:describe_groups",
        "//src/v/kafka/protocol:fetch",
        "//src/v/kafka/protocol:find_coordinator",
        "//src/v/kafka/protocol:flex_versions",
        "//src/v/kafka/protocol:heartbeat",
        "//src/v/kafka/protocol:join_group",
        "//src/v/kafka/protocol:leave_group",
        "//src/v/kafka/protocol:list_offset",
        "//src/v/kafka/protocol:metadata",
        "//src/v/kafka/protocol:offset_commit",
        "//src/v/kafka/protocol:offset_fetch",
        "//src/v/kafka/protocol:offset_for_leader_epoch",
        "//src/v/kafka/protocol:produce",
        "//src/v/kafka/protocol:sasl_authenticate",
        "//src/v/kafka/protocol:sasl_handshake",
        "//src/v/kafka/protocol:sync_group",
        "//src/v/net",
        "//src/v/ssx:future_util",
        "//src/v/utils:mutex",
        "//src/v/utils:prefix_logger",
        "//src/v/utils:unresolved_address",
        "@fmt",
        "@seastar",
    ],
)

redpanda_cc_library(
    name = "types",
    srcs = ["types.cc"],
    hdrs = ["types.h"],
    implementation_deps = [
        "//src/v/utils:to_string",
    ],
    visibility = ["//visibility:public"],
    deps = [
        "//src/v/base",
        "//src/v/bytes:iobuf",
        "//src/v/container:chunked_vector",
        "//src/v/kafka/protocol:metadata",
        "//src/v/model",
        "@fmt",
    ],
)

redpanda_cc_library(
    name = "brokers",
    srcs = [
        "broker.cc",
        "brokers.cc",
    ],
    hdrs = [
        "broker.h",
        "brokers.h",
    ],
    deps = [
        ":api_types",
        ":configuration",
        ":exceptions",
        ":logger",
        ":transport",
        ":types",
        "//src/v/base",
        "//src/v/container:chunked_vector",
        "//src/v/kafka/protocol:messages",
        "//src/v/kafka/protocol:metadata",
        "//src/v/kafka/protocol:sasl_authenticate",
        "//src/v/kafka/protocol:sasl_handshake",
        "//src/v/model",
        "//src/v/net",
        "//src/v/random:generators",
        "//src/v/security",
        "//src/v/ssx:future_util",
        "//src/v/thirdparty/c-ares",
        "//src/v/utils:backoff_policy",
        "//src/v/utils:mutex",
        "//src/v/utils:prefix_logger",
        "//src/v/utils:unresolved_address",
        "//src/v/version",
        "@abseil-cpp//absl/container:flat_hash_map",
        "@abseil-cpp//absl/container:flat_hash_set",
        "@fmt",
        "@seastar",
    ],
)

redpanda_cc_library(
    name = "partitioners",
    srcs = [
        "partitioners.cc",
    ],
    hdrs = [
        "partitioners.h",
    ],
    implementation_deps = [
        "//src/v/kafka/client:utils",
    ],
    deps = [
        ":exceptions",
        ":types",
        "//src/v/base",
        "//src/v/container:chunked_hash_map",
        "//src/v/hashing:murmur",
        "//src/v/kafka/protocol",
        "//src/v/kafka/protocol:metadata",
        "//src/v/model",
        "//src/v/random:generators",
        "@fmt",
    ],
)

redpanda_cc_library(
    name = "topic_cache",
    srcs = [
        "topic_cache.cc",
    ],
    hdrs = [
        "topic_cache.h",
    ],
    implementation_deps = [
        "//src/v/kafka/client:utils",
    ],
    deps = [
        ":exceptions",
        ":types",
        "//src/v/base",
        "//src/v/container:chunked_hash_map",
        "//src/v/container:chunked_vector",
        "//src/v/kafka/protocol:metadata",
        "//src/v/model",
        "@fmt",
        "@seastar",
    ],
)

redpanda_cc_library(
    name = "utils",
    srcs = [],
    hdrs = ["utils.h"],
    visibility = ["//visibility:public"],
    deps = [
        ":brokers",
        ":exceptions",
        ":logger",
        ":types",
        "//src/v/base",
        "//src/v/utils:retry",
    ],
)

redpanda_cc_library(
    name = "client",
    srcs = [
        "assignment_plans.cc",
        "client.cc",
        "client_fetch_batch_reader.cc",
        "consumer.cc",
        "fetch_session.cc",
        "fetcher.cc",
        "producer.cc",
    ],
    hdrs = [
        "assignment_plans.h",
        "client.h",
        "client_fetch_batch_reader.h",
        "consumer.h",
        "fetch_session.h",
        "fetcher.h",
        "fwd.h",
        "produce_batcher.h",
        "produce_partition.h",
        "producer.h",
    ],
    visibility = ["//visibility:public"],
    deps = [
        ":brokers",
        ":cluster",
        ":configuration",
        ":exceptions",
        ":logger",
        ":partitioners",
        ":topic_cache",
        ":transport",
        ":types",
        ":utils",
        "//src/v/base",
        "//src/v/bytes:iobuf",
        "//src/v/bytes:iobuf_parser",
        "//src/v/bytes:iostream",
        "//src/v/bytes:scattered_message",
        "//src/v/config",
        "//src/v/container:chunked_hash_map",
        "//src/v/container:chunked_vector",
        "//src/v/hashing:murmur",
        "//src/v/kafka/protocol",
        "//src/v/kafka/protocol:api_versions",
        "//src/v/kafka/protocol:create_topics",
        "//src/v/kafka/protocol:delete_records",
        "//src/v/kafka/protocol:describe_configs",
        "//src/v/kafka/protocol:describe_groups",
        "//src/v/kafka/protocol:fetch",
        "//src/v/kafka/protocol:find_coordinator",
        "//src/v/kafka/protocol:flex_versions",
        "//src/v/kafka/protocol:heartbeat",
        "//src/v/kafka/protocol:join_group",
        "//src/v/kafka/protocol:leave_group",
        "//src/v/kafka/protocol:list_offset",
        "//src/v/kafka/protocol:metadata",
        "//src/v/kafka/protocol:offset_commit",
        "//src/v/kafka/protocol:offset_fetch",
        "//src/v/kafka/protocol:offset_for_leader_epoch",
        "//src/v/kafka/protocol:produce",
        "//src/v/kafka/protocol:sasl_authenticate",
        "//src/v/kafka/protocol:sasl_handshake",
        "//src/v/kafka/protocol:sync_group",
        "//src/v/kafka/protocol/schemata:offset_commit_request",
        "//src/v/model",
        "//src/v/net",
        "//src/v/random:generators",
        "//src/v/security",
        "//src/v/ssx:future_util",
        "//src/v/ssx:semaphore",
        "//src/v/storage:record_batch_builder",
        "//src/v/strings:string_switch",
        "//src/v/thirdparty/c-ares",
        "//src/v/utils:mutex",
        "//src/v/utils:prefix_logger",
        "//src/v/utils:retry",
        "//src/v/utils:truncating_logger",
        "//src/v/utils:unresolved_address",
        "@abseil-cpp//absl/container:flat_hash_map",
        "@abseil-cpp//absl/container:flat_hash_set",
        "@abseil-cpp//absl/container:node_hash_map",
        "@abseil-cpp//absl/hash",
        "@fmt",
        "@seastar",
    ],
)

redpanda_cc_library(
    name = "cluster",
    srcs = ["cluster.cc"],
    hdrs = ["cluster.h"],
    visibility = ["//visibility:public"],
    deps = [
        ":brokers",
        ":configuration",
        ":exceptions",
        ":logger",
        ":topic_cache",
        ":transport",
        ":types",
        "//src/v/base",
        "//src/v/random:generators",
        "//src/v/ssx:future_util",
        "//src/v/ssx:work_queue",
        "//src/v/utils:notification_list",
        "//src/v/utils:prefix_logger",
        "//src/v/utils:unresolved_address",
        "@abseil-cpp//absl/container:flat_hash_map",
        "@fmt",
        "@seastar",
    ],
)
